/**
 * @description 应用加载器
 * */

import $pig from '@daelui/pigjs'

const isProd = process.env.NODE_ENV === 'production'
// 是否运行态
const ap = (window.application || {}).dpad || {}
ap.mode = ap[isProd ? 'prod' : 'dev']
// 初始化模块配置
const loader = ap.mode.loader || {}
const domain = ap.mode.domain || location.origin
const rootUrl = loader.rootUrl || location.origin
export default $pig.init({
  path: loader.path || rootUrl + '@daelui/pigjs/latest/dist/system.min.js',
  registry: loader.registry || location.origin + '/components.json',
  rootUrl: rootUrl,
  rootUrls: loader.rootUrls,
  versions: [{name: 'vue', version: '2.*.*'}]
}).then(function(){
  $pig.import(domain + '/dwas/dpad/app/static/css/main.css')
  return $pig.import(domain + '/dwas/dpad/app/static/js/chunk-vendors.js').then(() => {
    return $pig.import(domain + '/dwas/dpad/app/static/js/main.js')
  })
})
